#!/usr/bin python3
# -*- coding: utf-8 -*-
from sqlalchemy import Column, String, Text, DateTime, Float, Integer
from gtm_server.common.database_pg import Base

class TaskModel(Base):
    """
    任务信息数据表
    """
    __tablename__ = "tasks"

    id = Column("id", String(255), primary_key=True)
    name = Column("name", String(255))
    ori_lat = Column("ori_lat", Float(4))
    ori_lng = Column("ori_lng", Float(4))
    de_lat = Column("de_lat", Float(4))
    de_lng = Column("de_lng", Float(4))
    create_time = Column("create_time", DateTime())
    brief = Column("brief", String(255))
    pre_duration = Column("pre_duration", Integer())
    index = Column("index", Integer())
    steps = Column("steps", Integer())
    distance = Column("distance", Float(4))

    def __init__(self, id, name, ori_lat, ori_lng, de_lat, de_lng, create_time,
                 brief, pre_duration, index, steps, distance):
        self.id = id
        self.name = name
        self.ori_lat = ori_lat
        self.ori_lng = ori_lng
        self.de_lat = de_lat
        self.de_lng = de_lng
        self.create_time = create_time
        self.brief = brief
        self.pre_duration = pre_duration
        self.index = index
        self.steps = steps
        self.distance = distance


class StepModel(Base):
    """
    任务分段数据表
    """
    __tablename__ = "steps"

    id = Column("id", String(255), primary_key=True)
    task_id  = Column("task_id", String(255))
    leg_index = Column("leg_index", Integer(), primary_key=True)
    direction = Column("direction", Integer())
    distance = Column("distance", Float(8))
    road_name = Column("road_name", String(255))
    road_type = Column("road_type", String(255))
    start_lat = Column("start_lat", Float(8))
    start_lng = Column("start_lng", Float(8))
    end_lat = Column("end_lat", Float(8))
    end_lng = Column("end_lng", Float(8))
    path = Column("path", Text(255))
    no = Column("no", Integer())

    def __init__(self, id, task_id, leg_index, direction, distance, road_name, road_type,
                 start_lat, start_lng, end_lat, end_lng, path, no):
        self.id = id
        self.task_id = task_id
        self.leg_index = leg_index
        self.direction = direction
        self.distance = distance
        self.road_name = road_name
        self.road_type = road_type
        self.start_lat = start_lat
        self.start_lng = start_lng
        self.end_lat = end_lat
        self.end_lng = end_lng
        self.path = path
        self.no = no
